<html>
<head><meta charset="utf-8"><title>does no_mangle prevents inlining? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html">does no_mangle prevents inlining?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="223976077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976077">(Jan 25 2021 at 23:09)</a>:</h4>
<p>Hi, I know that <code>#[no_mangle]</code> does more than just name-mangling (e.g. exporting a symbol and marking it as used), but it seems to prevent calls from being inlined. Is this intentional? and if so, is there an alternative that still allows the optimiser to inline calls to no_mangled functions?</p>



<a name="223976236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976236">(Jan 25 2021 at 23:10)</a>:</h4>
<p>It doesn't prevent inlining</p>



<a name="223976266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976266">(Jan 25 2021 at 23:10)</a>:</h4>
<p>That does not appear to be the case: <a href="https://play.rust-lang.org/?version=stable&amp;mode=release&amp;edition=2018&amp;gist=9d8cb87771f017fb2f8136745516c2aa">https://play.rust-lang.org/?version=stable&amp;mode=release&amp;edition=2018&amp;gist=9d8cb87771f017fb2f8136745516c2aa</a></p>



<a name="223976303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976303">(Jan 25 2021 at 23:11)</a>:</h4>
<p>It does export the function though, so that can affect inlining decisions</p>



<a name="223976313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976313">(Jan 25 2021 at 23:11)</a>:</h4>
<p><span class="user-mention" data-user-id="243558">@Steven Fackler</span> your example does appear inlined, no?</p>



<a name="223976320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976320">(Jan 25 2021 at 23:12)</a>:</h4>
<p>as well as the exported version</p>



<a name="223976358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976358">(Jan 25 2021 at 23:12)</a>:</h4>
<p>right yeah</p>



<a name="223976365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976365">(Jan 25 2021 at 23:12)</a>:</h4>
<p>by "case" I meant "prevents calls from being inlined"</p>



<a name="223976393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976393">(Jan 25 2021 at 23:13)</a>:</h4>
<p>This is a case of two people responding at the same time making the reference refer to the wrong thing.</p>



<a name="223976433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976433">(Jan 25 2021 at 23:13)</a>:</h4>
<p>even Rust forums don't prevent thread races</p>



<a name="223976667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976667">(Jan 25 2021 at 23:16)</a>:</h4>
<p>you're right. something is preventing inlining in my example but it seems i jumped to the conclusion that it was no_mangle, i should have checked this in playground first. sorry for the noise</p>



<a name="223976942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976942">(Jan 25 2021 at 23:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="211727">Jonas Schievink</span> <a href="#narrow/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F/near/223976303">said</a>:</p>
<blockquote>
<p>It does export the function though, so that can affect inlining decisions</p>
</blockquote>
<p>Ah, and this is  heuristic based, where theoretically an exported symbol could be the final straw that tipped it over into the no territory?</p>



<a name="223976994"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223976994" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223976994">(Jan 25 2021 at 23:20)</a>:</h4>
<p>yeah</p>



<a name="223977069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/does%20no_mangle%20prevents%20inlining%3F/near/223977069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Hughes <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/does.20no_mangle.20prevents.20inlining.3F.html#223977069">(Jan 25 2021 at 23:21)</a>:</h4>
<p>thanks, that gives me something to work with :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>